package Solution;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Solution {

        public static int[] findErrorNums(int[] nums) {
            int[] errorNums = new int[2];
            int n = nums.length;
            Map<Integer, Integer> map = new HashMap<Integer, Integer>();
            for (int num : nums) {
                map.put(num, map.getOrDefault(num, 0) + 1);
            }
            for (int i = 1; i <= n; i++) {
                int count = map.getOrDefault(i, 0);
                if (count == 2) {
                    errorNums[0] = i;
                } else if (count == 0) {
                    errorNums[1] = i;
                }
            }
            return errorNums;
        }

    public static void main(String[] args) {

        int[]  n = {1,2,3,3,5};
        System.out.println(findErrorNums(n));
    }
    }



